package com.hth.eureka.consumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication(scanBasePackages = "com.hth.eureka.consumer")
@PropertySource("classpath:application-consumer.properties")
@EnableEurekaClient
public class EurekaApplicationConsumer {

	public static void main(String[] args) {
		SpringApplication.run(EurekaApplicationConsumer.class, args);
	}

	@Bean
	@LoadBalanced // 加上LoadBalanced注解自动配置Ribbon生效
	RestTemplate getRestTemplate() {

		RestTemplate restTemplate = new RestTemplate();
//		restTemplate.getInterceptors().add(new LoggingClientHttpRequestInterceptor());
		return restTemplate;
	}

}
